package com.itheima.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.domain.UmsRoleMenuRelation;
import com.itheima.domain.UmsRoleResourceRelation;
import com.itheima.mapper.UmsRoleResourceRelationMapper;
import com.itheima.service.UmsRoleResourceRelationService;
import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 后台角色资源关系表 服务实现类
 * </p>
 *
 * @author zhuguo
 * @since 2022-11-10
 */
@DubboService
public class UmsRoleResourceRelationServiceImpl extends ServiceImpl<UmsRoleResourceRelationMapper, UmsRoleResourceRelation> implements UmsRoleResourceRelationService {

    @Autowired
    private UmsRoleResourceRelationMapper umsRoleResourceRelationMapper;


    @Override
    public void removeByRoleId(Long roleId) {
        LambdaQueryWrapper<UmsRoleResourceRelation> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UmsRoleResourceRelation::getRoleId, roleId);
        umsRoleResourceRelationMapper.delete(wrapper);
    }

    @Override
    public List<UmsRoleResourceRelation> getByRoleId(Long roleId) {
        LambdaQueryWrapper<UmsRoleResourceRelation> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(UmsRoleResourceRelation::getRoleId, roleId);
        return umsRoleResourceRelationMapper.selectList(wrapper);
    }
}
